/**
 * 计数排序 一定范围内的整数
 */
Array.prototype.count = function(){
     
    let maxEle = Math.max(...this);
    let minEle = Math.min(...this);
    // 构建一个临时数组统计源数组中元素出现的次数
    let tem = [];
    for(let i = minEle ;i <= maxEle ;i++){
         tem.push(0);
    }
    for(let j = 0; j < this.length ; j++){
          tem[this[j]-minEle]++    
    }
     // 遍历统计数组获取排序后的数组
    let target = []
    for(let k = 0 ;k < tem.length ; k++){
         let ele = k + minEle;
         let count = tem[k];
         for(let n = count ; n > 0 ; n--){
             target.push(ele)
         }
    }
    return target
}

let a = [1,5,9,20,1,2,5,3,10,15];
console.log(a.count());